@extends('layouts.app')

@section('title','CreateMasterVideo')

@section('content')
    <div class="container">
        <div class="row">
            <div class="col-md-8 col-md-offset-2 create-question">
                <div class="panel panel-default">
                    <div class="panel-heading">添加大师视频</div>
                    <div class="panel-body">
                        {!! Form::open(['route' => 'mvideo.store', 'files' => true]) !!}
                        {{ csrf_field() }}
                        <div class="form-group{{ $errors->has('video_name')?'has-error':'' }}">
                            {!! Form::label('video_name','视频名')!!}
                            {!! Form::text('video_name',null,['class'=>'form-control'])!!}
                            @if ($errors->has('video_name'))
                                <span class="help-block">
						                <strong>{{ $errors->first('video_name') }}</strong>
						            </span>
                            @endif
                        </div>
                        <div class="form-group">
                            {!! Form::label('video_pic','视频图片')!!}
                            <div class="input-group">
                                {!! Form::file('video_pic') !!}
                                @if ($errors->has('video_pic'))
                                    <div class="help-block">
                                        <strong>{{ $errors->first('video_pic') }}</strong>
                                    </div>
                                @endif
                            </div>
                        </div>
                        <div class="form-group">
                            <label>视频文件：</label>
                            <div class="inpt-group">
                                <input type="file" id="aetherupload-file" onchange="AetherUpload.upload('file')"/>
                                <!--need to have an id "aetherupload-file" here for the file to be uploaded, 'file' is the default group name in config/aetherupload.php-->
                                <div class="progress "
                                     style="height: 6px;margin-bottom: 2px;margin-top: 10px;width: 200px;">
                                    <div id="aetherupload-progressbar"
                                         style="background:blue;height:6px;width:0;"></div>
                                    <!--need to have an id "aetherupload-progressbar" here for the progress bar-->
                                </div>
                                <span style="font-size:12px;color:#aaa;" id="aetherupload-output">等待上传</span>
                                <!--need to have an id "aetherupload-output" here for the prompt message-->
                            </div>
                            <input type="hidden" name="savedpath" id="aetherupload-savedpath" value="">
                            <!--need to have an id "aetherupload-savedpath"  and a name "savedpath" here for the saved path of the uploaded file-->
                            <div>
                                <p>原文件名：<span id="test1"></span></p>
                                <p>原文件大小：<span id="test2"></span></p>
                                <p>储存文件名：<span id="test3"></span></p>
                            </div>
                        </div>
                        <hr/>

                        <div class="form-group{{ $errors->has('video_intro')?'has-error':'' }}">
                            {!! Form::label('video_intro','个人简介') !!}
                            <div class="input-group">
                                {!! Form::textarea('video_intro',null,['class'=>'form-control']) !!}
                                @if ($errors->has('video_intro'))
                                    <span class="help-block">
				                        <strong>{{ $errors->first('video_intro') }}</strong>
				                    </span>
                                @endif
                            </div>
                        </div>

                        {!! Form::submit('添加大师视频',['class'=>"btn btn-success"]); !!}
                        {!! Form::close() !!}
                    </div>
                    <div id="debug"></div>
                </div>
            </div>
        </div>
    </div>
@endsection

@section('js')
    <script src="{{ URL::asset('js/spark-md5.min.js') }}"></script><!--need to have spark-md5.js for md5 calculation-->
    <script src="{{ URL::asset('js/aetherupload.js') }}"></script><!--need to have aetherupload.js-->
    <script>
        // this function will be called after file is uploaded successfully
        // you can get fileName,fileSize,uploadExt,chunkCount,chunkSize,subDir,group,savedPath of the uploaded file
        AetherUpload.success = function () {
            // Example
            $('#test1').text(this.fileName);
            $('#test2').text(parseFloat(this.fileSize / (1000 * 1000)).toFixed(2) + 'MB');
            $('#test3').text(this.savedPath.substr(this.savedPath.lastIndexOf('/') + 1));
        };
    </script>
@endsection